<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>设备管理</title>
<script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {

		$('#sect1').blur(function(){
			var sect1=document.getElementById('sect1').value;
			getSect1(sect1)
		})
		
		$('#search').blur(function(){
			var search=document.getElementById('search').value;
			getSearch(search)
		})
	})
	
	function getSearch(search){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/getSearch.action',
			data:'search='+search,
			success:function(data){
				
			}
		})
	}

	function getSect1(sect1){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/getSect1.action',
			data:'sect1='+sect1,
			success:function(data){
				
			}
		})
	}
	function getradio() {

		var radioval = $('#wrap input[name="payMethod"]:checked ').val();
		setSwift(radioval)
	}
	
	function setSwift(data){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/setSwift.action',
			data:'swift='+data,
			success:function(data){
				setList()
			}			
		})		
	}
	
	function getList(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/getList.action',
			success:function(data){
				init()
			}
		})
	}
	
	function nextPage(end) {
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/nextPage.action',
			data:'end='+end,
			success:function(data){
				init()
			}
		})
	}
	
	function lastPage(begin){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/lastPage.action',
			data:'begin='+begin,
			success:function(data){
				init()
			}
		})
	}
	function setList(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/setList.action',
			success:function(data){
				init()
			}
		})
	}
	
	function setIndex(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/setIndex.action',
			success:function(data){
				init()
			}
		})
	}
	
	function searchEquip(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/searchEquip.action',
			success:function(data){
				init()
			}
		})
	}	
	
	function init() {
		window.location.href="${pageContext.request.contextPath}/equipment/getList.action";
	}
</script>
</head>
<body>

	<div id="container" style="width: 1500px">

		<div id="header" style="">
			
			<c:forEach items="${searchList}" var="search">
			<p>安装地址:&nbsp;&nbsp;&nbsp;${search.install}</p>
			</c:forEach>
			
			设备信息：<select name="option1" id="sect1">
				<option value="equipId">设备ID</option>
				<option value="equipName">设备名称</option>
			</select> <input type="text" id="search">
			<button onclick="searchEquip()">查询</button>
			<button>重置</button>

		</div>



		<div id="menu"
			style="background-color:; height: 600px; width: 400px; float: left; margin-top: 30px;">
			<button onclick="setList()">显示全部数据</button>
			<button onclick="getradio()">保存</button>
			<hr>
			<table cellspacing="0" cellpadding="0" border="1" width="400px"
				style="text-align: center">
				<tr>
					<td>设备ID</td>
					<td>运行状态</td>
					<td>开启/关闭</td>
				</tr>
				<c:forEach items="${equipList}" var="equip" begin="${begin}"
					end="${end-1}">
					<tr>
						<td>${equip.eqipId}</td>
						<td>${equip.status}</td>
						<td>
							<div id="wrap">
								<input type="radio" name="payMethod" value="${equip.id}=1" />开启
								<input type="radio" name="payMethod" value="${equip.id}=0" />关闭
							</div>
						</td>
					</tr>
				</c:forEach>
			</table>

		</div>

		<div id="content"
			style="background-color:; height: 500px; width: 600px; float: left; margin-left: 50px;">
			<table cellspacing="0" cellpadding="0" border="1" width="600px"
				style="text-align: center">
				<tr>
					<td>设备名称</td>
					<td>序号</td>
					<td>设备ID</td>
					<td>额定电流</td>
					<td>额定电压</td>
				</tr>
				<c:forEach items="${equipList}" var="equip" begin="${begin}"
					end="${end-1}">
					<tr>
						<td>${equip.eqipName}</td>
						<td>${equip.serial}</td>
						<td>${equip.eqipId}</td>
						<td>${equip.elecRate}</td>
						<td>${equip.elecVol}</td>
					</tr>
				</c:forEach>
			</table>
			<hr>
			<p>共有 &nbsp;${size}&nbsp;条记录，当前&nbsp;${page}-&nbsp;${currentPage}页<p>
			<button onclick="setIndex()">首页</button>
			<button onclick="lastPage(${begin})">上一页</button>
			<button onclick="nextPage(${end-1})">下一页</button>
			转到第<input type="text" style="width: 15px;">页

		</div>

		<div id="footer" style="clear: both; text-align: center;">版权 ©
			licongcong.top</div>

	</div>

</body>
</html>